home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 1 / Pier Shareware 1.iso / 007a / courspas.exe / CHAP17.EXE / POOGRAPH.PAS < prev    next >
Pascal/Delphi Source File  |  1991-01-11  |  5KB  |  176 lines

  1. unit poograph;  {POOGRAPH.PAS}
  2. {------------------------------------------------}
  3. { Interface                                      }
  4. {------------------------------------------------}
  5. interface
  6. uses
  7.   graph, crt;  {unité de Turbo Pascal 6 }
  8.  
  9. type
  10.   axe = object
  11.                   X1, Y1: integer;
  12.                   procedure init (initX1, initY1: integer);
  13.                 end;
  14.  
  15.   Point = object (axe)
  16.             X2, Y2: integer;
  17.             constructor init (initX1, initY1,
  18.                               initX2, initY2: integer);
  19.             procedure afficher; virtual;
  20.             procedure effacer; virtual;
  21.             procedure tourner;
  22.           end;
  23.  
  24.   Trait = object (Point)
  25.             procedure afficher; virtual;
  26.             procedure effacer; virtual;
  27.           end;
  28.  
  29.   Rectangl = object (Point)
  30.                procedure afficher; virtual;
  31.                procedure effacer; virtual;
  32.              end;
  33.  
  34.   Boite = object (Point)
  35.              profondeur: word;
  36.              position: boolean;
  37.              constructor Init (initX1, initY1,
  38.                                initX2, initY2: integer;
  39.                                initprofondeur: word;
  40.                                initposition: boolean);
  41.              procedure afficher; virtual;
  42.              procedure effacer; virtual;
  43.            end;
  44.  
  45. {------------------------------------------------}
  46. { Implementation                                 }
  47. {------------------------------------------------}
  48. implementation
  49.  
  50.   {----------------------------------------------------}
  51.   { Méthodes de axe                                    }
  52.   {----------------------------------------------------}
  53.  
  54.   procedure axe.init (initX1, initY1: integer);
  55.   begin
  56.     x1 := initX1;
  57.     y1 := initY1;
  58.   end;
  59.  
  60.   {----------------------------------------------------}
  61.   { Méthodes de Point                                  }
  62.   {----------------------------------------------------}
  63.  
  64.   constructor Point.Init (InitX1, InitY1,
  65.                           initX2, initY2:integer);
  66.   begin;
  67.     axe.init (initX1, InitY1);
  68.     X2 := initX2;
  69.     Y2 := initY2;
  70.   end;
  71.  
  72.   procedure Point.afficher;
  73.   begin
  74.     putpixel (x1, y1, 14);
  75.     putpixel (x2, y2, 14);
  76.   end;
  77.  
  78.   procedure Point.effacer;
  79.   begin
  80.       putpixel (x1, y1, getbkcolor);
  81.       putpixel (x2, y2, getbkcolor);
  82.   end;
  83.  
  84.   procedure Point.tourner;
  85.   var
  86.     r,i,xa: integer;
  87.     X1tmp, Y1tmp, X2tmp, Y2tmp: integer;
  88.   begin
  89.     xa := 0;
  90.     X1tmp := x1;
  91.     Y1tmp := y1;
  92.     X2tmp := x2;
  93.     Y2tmp := y2;
  94.     r := getmaxy div 5;
  95.     for i := 1 to 630 do
  96.     begin;
  97.       xa := xa+1;
  98.       Y2tmp := Y1tmp-round(r*cos(xa/100));
  99.       case xa of
  100.         1..157  : X2tmp := X1tmp+xa;
  101.         158..314: X2tmp := X1tmp+314-xa;
  102.         315..470: X2tmp := X1tmp+314-xa;
  103.         471..630: X2tmp := X1tmp-630+xa;
  104.       end;
  105.       Point.init (X1tmp, Y1tmp, X2tmp, Y2tmp);
  106.       afficher;
  107.       delay(15);
  108.       effacer;
  109.     end;
  110.   end;
  111.  
  112.   {----------------------------------------------------}
  113.   { Méthodes de Trait                                  }
  114.   {----------------------------------------------------}
  115.  
  116.   procedure Trait.afficher;
  117.   begin
  118.     moveto (x1, y1);
  119.     setcolor(14);
  120.     lineto (x2, y2);
  121.   end;
  122.  
  123.   procedure Trait.effacer;
  124.   begin
  125.     moveto (x1, y1);
  126.     setcolor (getbkcolor);
  127.     lineto (x2, y2);
  128.   end;
  129.  
  130.   {----------------------------------------------------}
  131.   { Méthodes de Rectangl                              }
  132.   {----------------------------------------------------}
  133.  
  134.   procedure Rectangl.afficher;
  135.   begin;
  136.     setcolor(14);
  137.     rectangle (x1, y1, x2, y2);
  138.   end;
  139.  
  140.   procedure Rectangl.effacer;
  141.   begin;
  142.     setcolor (getbkcolor);
  143.     rectangle (x1, y1, x2, y2);
  144.   end;
  145.  
  146.   {----------------------------------------------------}
  147.   { Méthodes de Boite                                  }
  148.   {----------------------------------------------------}
  149.  
  150.   constructor Boite.Init (initX1, initY1,
  151.                            initX2, initY2: integer;
  152.                            initprofondeur: word;
  153.                            initposition: boolean);
  154.   begin
  155.     Point.init (initx1, inity1, initx2, inity2);
  156.     profondeur := initprofondeur;
  157.     position := initposition;
  158.   end;
  159.  
  160.   procedure boite.afficher;
  161.   begin;
  162.     setcolor(14);
  163.     bar3d (x1, y1, x2, y2, profondeur, position);
  164.   end;
  165.  
  166.   procedure boite.effacer;
  167.   begin
  168.     setcolor (getbkcolor);
  169.     if x2 < 162 then y2 := y2+1;
  170.     bar3d (x1, y1, x2, y2, profondeur, position);
  171.   end;
  172. {------------------------------------------------}
  173. { End of Unit                                    }
  174. {------------------------------------------------}
  175. end.
  176.